#include <iostream>
#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>

#define FIFO_FILE "myfifo"
#define MOOD 0664

enum
{
    FIFO_FREATE_ERR = 1,
    FIFO_DELETE_ERR ,
    FIFO_OPEN_ERR
};


class Init
{
public:
    Init()
    {
        int n = mkfifo(FIFO_FILE, MOOD);
        if(n == -1)
        {
            perror("mkfifo fail\n");
            exit(FIFO_FREATE_ERR);
        }
    }

    ~Init()
    {
        //清理管道
        int m = unlink(FIFO_FILE);
        if(m == -1)
        {
            perror("unlink");
            exit(FIFO_DELETE_ERR);
        }
    }

};